package generator.groupclass;

import generator.structure.Pair;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class Uncandidate implements Serializable{

	int listLength;
	
	int[] keys;
	
	int distinct;
	
	public Uncandidate() {
		
	}

	Map<Integer, ArrayList<Pair<String, Integer>>> uncandiAccum = 
			new HashMap<Integer, ArrayList<Pair<String, Integer>>>();

	public Map<Integer, ArrayList<Pair<String, Integer>>> getUncandiAccum() {
		
		return uncandiAccum;
	}
	
	public void setUncandiAccum(Map<Integer, ArrayList<Pair<String, Integer>>> uncandiAccum) {
		
//		System.out.println("setUncandiAccum: ");
//		System.out.println(uncandiAccum);
//		System.out.println("distinct: " + distinct);
		
		this.uncandiAccum = uncandiAccum;
		
		Set<Integer> key = new HashSet<Integer>(uncandiAccum.keySet());
//		System.out.println("key:" + key);
		
		listLength = key.size();
//		System.out.println("listLength: " + listLength);
		
		keys = new int[listLength];
		
		int i = 0;
		for(Iterator<Integer> ite = key.iterator(); ite.hasNext();) {
			keys[i] = ite.next();
//			System.out.println(keys[i]);
			i++;
		}
		
	}
	
	public int getDistinct() {
		
		return distinct;
	}
	
	public int getListLength() {
		
		return listLength;
	}
	
	public int[] getKeys() {
		
		return keys;
	}
	
//	public void write(String output) {
//		
//		File output_ = new File(output);
//		output_.mkdirs();
//		
//		String outputFile = "";
//		
//		PrintWriter pw = null;
//		for(int i = 0; i < listLength; i++) {
//			
//			int column = keys[i];
//			outputFile = output + "/" + column;
//			ArrayList<Pair<String, Integer>> accum = uncandiAccum.get(column);
//			
//			try {
//				pw = new PrintWriter(new FileWriter(outputFile));
//				
//				for(int line = 0; line < accum.size(); line++) {
//					String keyString = accum.get(line).first_;
//					int cum = accum.get(line).second_;
//					pw.println(keyString + "\t" + cum);
//				}
//				
//				pw.close();
//			} catch (IOException e) {
//				// TODO Auto-generated catch block
//				e.printStackTrace();
//			}
//		}
//		
//	}
	
}
